home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / TreeViewBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  198 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Fixed misspelling of descriptions.
  8. //  10/09/97    LAB    Added setShortDescription for treeStructure.
  9. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  10.  
  11. /**
  12.  * BeanInfo for TreeView.
  13.  *
  14.  */
  15. public class TreeViewBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a TreeViewBeanInfo object.
  19.      */
  20.     public TreeViewBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupAWTAdditions"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setCanAddChild(false);
  47.         bd.setFolder(s);
  48.         bd.setWinHelp("0x12398");
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("TreeViewC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("TreeViewC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = null;
  96.             MethodDescriptor getCount = new MethodDescriptor(beanClass.getMethod("getCount", args));
  97.  
  98.             connections = new java.util.Vector();
  99.             connection = new ConnectionDescriptor("output", "int", "",
  100.                                     "%name%.getCount()",
  101.                                     conn.getString("getCount"));
  102.             connections.addElement(connection);
  103.  
  104.             getCount.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  105.             md.addElement(getCount);
  106.         } catch (Exception e) { throw new Error("getCount:: " + e.toString()); }
  107.  
  108.         try{
  109.             args = null;
  110.             MethodDescriptor getSelectedText = new MethodDescriptor(beanClass.getMethod("getSelectedText", args));
  111.  
  112.             connections = new java.util.Vector();
  113.             connection = new ConnectionDescriptor("output", "String", "",
  114.                                     "%name%.getSelectedText()",
  115.                                     conn.getString("getSelectedText"));
  116.             connections.addElement(connection);
  117.  
  118.             getSelectedText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  119.             md.addElement(getSelectedText);
  120.         } catch (Exception e) { throw new Error("getSelectedText:: " + e.toString()); }
  121.  
  122.         try{
  123.             args = null;
  124.             MethodDescriptor getViewCount = new MethodDescriptor(beanClass.getMethod("getViewCount", args));
  125.  
  126.             connections = new java.util.Vector();
  127.             connection = new ConnectionDescriptor("output", "int", "",
  128.                                     "%name%.getViewCount()",
  129.                                     conn.getString("getViewCount"));
  130.             connections.addElement(connection);
  131.  
  132.             getViewCount.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  133.             md.addElement(getViewCount);
  134.         } catch (Exception e) { throw new Error("getViewCount:: " + e.toString()); }
  135.  
  136.         try{
  137.             args = new Class[1];
  138.             args[0] = java.lang.String.class ;
  139.             MethodDescriptor remove = new MethodDescriptor(beanClass.getMethod("remove", args));
  140.  
  141.             connections = new java.util.Vector();
  142.             connection = new ConnectionDescriptor("input", "String", "",
  143.                                     "%name%.remove(%arg%);",
  144.                                     conn.getString("remove"));
  145.             connections.addElement(connection);
  146.  
  147.             remove.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  148.             md.addElement(remove);
  149.         } catch (Exception e) { throw new Error("remove:: " + e.toString()); }
  150.  
  151.         try{
  152.             args = new Class[2];
  153.             args[0] = symantec.itools.awt.TreeNode.class ;
  154.             args[1] = java.lang.Boolean.TYPE ;
  155.             MethodDescriptor printTree = new MethodDescriptor(beanClass.getMethod("printTree", args));
  156.  
  157.             connections = new java.util.Vector();
  158.             connection = new ConnectionDescriptor("input", "void", "",
  159.                                     "%name%.printTree(%name%.getRootNode(), true);",
  160.                                     conn.getString("printTree"));
  161.             connections.addElement(connection);
  162.  
  163.             printTree.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  164.             md.addElement(printTree);
  165.         } catch (Exception e) { throw new Error("printTree:: " + e.toString()); }
  166.  
  167.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  168.         md.copyInto(rv);
  169.  
  170.         return rv;
  171.     }
  172.  
  173.     /**
  174.      * Returns descriptions of this bean's properties.
  175.      */
  176.     public PropertyDescriptor[] getPropertyDescriptors() {
  177.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  178.  
  179.         try{
  180.         PropertyDescriptor treeStructure = new PropertyDescriptor("treeStructure", beanClass);
  181.         treeStructure.setBound(true);
  182.         treeStructure.setConstrained(false);
  183.         treeStructure.setDisplayName(prop.getString("treeStructure"));
  184.         treeStructure.setShortDescription(prop.getString("TVSDescription"));
  185.  
  186.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  187.         layout.setHidden(true);
  188.  
  189.         PropertyDescriptor[] rv = {
  190.             treeStructure,
  191.             layout};
  192.         return rv;
  193.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  194.     }
  195.  
  196.     private final static Class beanClass = TreeView.class;
  197.  
  198.     }    //  end of class TreeViewBeanInfo